﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Webdiyer.AspNetCore;
using PlatformNetCore.Entity;
using PlatformNetCore.IRepository;

namespace PlatformNetCore.Repository
{
    public class ImagesRepository : Repository<Images>, IImagesRepository
    {
        public ImagesRepository(PlatformContext dbContext) : base(dbContext)
        {

        }

        public override PagedList<Images> GetPagedList(int pageIndex, int pageSize, Expression<Func<Images, bool>> predicate)
        {
            return _dbContext.Images.Where(predicate).OrderByDescending(k => k.AddDate).ToPagedList(pageIndex, pageSize);
        }

        public override PagedList<Images> GetPagerList(int pageIndex, int pageSize, Expression<Func<Images, bool>> predicate)
        {
            return _dbContext.Images.Where(predicate).OrderBy(m => m.SortNo).ThenByDescending(k => k.AddDate).ToPagedList(pageIndex, pageSize);
        }

        public override IEnumerable<Images> GetList(Expression<Func<Images, bool>> predicate)
        {
            return _dbContext.Images.Where(predicate).OrderBy(m => m.SortNo).ThenByDescending(k => k.AddDate);
        }
    }
}
